#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
简单的路径测试脚本
"""

import os
import sys

# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

def test_path_construction():
    """测试路径构建"""
    print("=" * 50)
    print("路径构建测试")
    print("=" * 50)
    
    # 获取root_path
    from config.config import root_path
    print(f"root_path: {root_path}")
    
    # 测试相对路径
    relative_path = "DataDriven/global/send_code.yaml"
    print(f"相对路径: {relative_path}")
    
    # 构建完整路径
    full_path = os.path.join(root_path, relative_path)
    print(f"完整路径: {full_path}")
    
    # 检查文件是否存在
    if os.path.exists(full_path):
        print("✓ 文件存在")
        return True
    else:
        print("✗ 文件不存在")
        return False

def test_yaml_read():
    """测试YAML读取"""
    print("\n" + "=" * 50)
    print("YAML读取测试")
    print("=" * 50)
    
    try:
        from core.YamlLoad import read_file
        print("✓ YamlLoad导入成功")
        
        # 测试读取文件
        result = read_file("DataDriven/global/send_code.yaml")
        print("✓ 文件读取成功！")
        print(f"文件内容: {result}")
        return True
        
    except Exception as e:
        print(f"✗ 测试失败: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    print("开始测试...")
    
    # 测试路径构建
    path_ok = test_path_construction()
    
    # 测试YAML读取
    yaml_ok = test_yaml_read()
    
    print("\n" + "=" * 50)
    if path_ok and yaml_ok:
        print("✓ 所有测试都通过了！")
    else:
        print("✗ 测试发现问题")
    print("=" * 50)
